/*     */ import java.awt.Color;
/*     */ import java.awt.Container;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Font;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.Insets;
/*     */ import java.awt.event.ActionEvent;
/*     */ import java.awt.event.ActionListener;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.awt.event.MouseMotionListener;
import java.awt.geom.Line2D;
/*     */ import java.awt.geom.Line2D.Double;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.Arrays;
/*     */ import java.util.List;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.Box;
/*     */ import javax.swing.BoxLayout;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JDialog;
/*     */ import javax.swing.JFrame;
/*     */ import javax.swing.JLabel;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JPanel;
/*     */ import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
/*     */ 
/*     */ public class PPOChart extends JPanel
/*     */   implements MouseMotionListener, BBIInterface, ActionListener
/*     */ {
/*     */   private SymQuotes sq;
/*     */   private String sym;
/*  14 */   private float yScale = 1.0F;
/*  15 */   private float xScale = 1.0F;
/*     */   private double stickWidth;
/*     */   private float minVal;
/*     */   private float maxVal;
/*     */   private int parm1;
/*     */   private int parm2;
/*     */   private int parm3;
/*     */   private float[] ma_parm1;
/*     */   private float[] ma_parm2;
/*     */   private float[] ppo_parm1_parm2;
/*     */   private float[] ppoEma_parm3;
/*  23 */   private String m = "";
/*     */   private int mX;
/*     */   private int mY;
/*  25 */   public int noOfDays = 150;
/*     */   private double p1Y;
/*     */   private double p2Y;
/*     */   private double p11Y;
/*     */   private double p22Y;
/*     */   private double p0Y;
/*     */   private double hY;
/*     */   private JTextField parm1TF;
/*     */   private JTextField parm2TF;
/*     */   private JTextField parm3TF;
/*     */   private JButton chgParmOk;
/*     */   private JButton chgParmCancel;
/*     */   private JButton defaultParms;
/*     */   private JDialog chgParmDialog;
/*  33 */   private DecimalFormat df = new DecimalFormat("0.00");
/*     */ 
/*  35 */   public String trend = "";
/*     */   public PPOChart.EastPanel ep;
/*     */   private double refY;
/*     */   private double refX;
/* 563 */   private Font ssp10 = new Font("SansSerif", 0, 10);
/* 564 */   private Font ssp9 = new Font("SansSerif", 0, 9);
/* 565 */   private Line2D.Double refL1 = new Line2D.Double();
/* 566 */   private Line2D.Double refL2 = new Line2D.Double();
/* 567 */   private Line2D.Double gridY = new Line2D.Double();
/* 568 */   private Line2D.Double gridX = new Line2D.Double();
/* 569 */   private Line2D.Double yrefL1 = new Line2D.Double();
/* 570 */   private Line2D.Double yrefL2 = new Line2D.Double();
/*     */   private double yfactor;
/*     */   private double startPointX;
/*     */   private int dateRef;
/*     */   private int daysRef;
/* 575 */   private Line2D.Double l0 = new Line2D.Double();
/* 576 */   private Line2D.Double l1 = new Line2D.Double();
/* 577 */   private Line2D.Double l2 = new Line2D.Double();
/* 578 */   private Line2D.Double hL = new Line2D.Double();
/*     */   private double x1;
/*     */   private double y1;
/*     */   private double x2;
/*     */   private double y2;
/*     */   private double u1;
/*     */   private double v1;
/*     */   private double u2;
/*     */   private double v2;
/*     */   private double a1;
/*     */   private double b1;
/*     */   private double a2;
/*     */   private double b2;
/*     */   private double xi;
/*     */   private double yi;
/* 580 */   private Line2D.Double uA = new Line2D.Double();
/* 581 */   private Line2D.Double lA = new Line2D.Double();
/* 582 */   private Line2D.Double hA = new Line2D.Double();
/*     */ 
/*     */   public PPOChart(SymQuotes paramSymQuotes, int paramInt1, int paramInt2, int paramInt3)
/*     */   {
/*  41 */     this.sq = paramSymQuotes;
/*  42 */     this.sym = paramSymQuotes.sym;
/*     */ 
/*  44 */     this.ma_parm1 = new float[paramSymQuotes.count];
/*  45 */     this.ma_parm2 = new float[paramSymQuotes.count];
/*  46 */     this.ppo_parm1_parm2 = new float[paramSymQuotes.count];
/*  47 */     this.ppoEma_parm3 = new float[paramSymQuotes.count];
/*     */ 
/*  49 */     this.parm1 = paramInt1;
/*  50 */     this.parm2 = paramInt2;
/*  51 */     this.parm3 = paramInt3;
/*     */ 
/*  53 */     if (this.noOfDays == 150)
/*  54 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/*  56 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/*  58 */     setBackground(Color.black);
/*  59 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */ 
/*  61 */     if (paramInt1 < paramSymQuotes.count) {
/*  62 */       maNdayFinder(paramInt1);
/*     */     }
/*  64 */     if (paramInt2 < paramSymQuotes.count) {
/*  65 */       maNdayFinder(paramInt2);
/*  66 */       ppo_parm1_parm2Finder();
/*     */     }
/*     */ 
/*  69 */     if (paramInt2 + paramInt3 < paramSymQuotes.count) {
/*  70 */       ppoEma_parm3Finder();
/*     */     }
/*  72 */     findMinMax();
/*  73 */     addMouseMotionListener(this);
/*     */ 
/*  75 */     if (this.ppo_parm1_parm2[(paramSymQuotes.count - 1)] >= this.ppoEma_parm3[(paramSymQuotes.count - 1)])
/*  76 */       this.trend = "Bullish";
/*     */     else {
/*  78 */       this.trend = "Bearish";
/*     */     }
/*  80 */     this.ep = new PPOChart.EastPanel();
/*     */   }
/*     */ 
/*     */   public void changeNoOfDays(int paramInt)
/*     */   {
/*  87 */     this.noOfDays = paramInt;
/*     */ 
/*  89 */     if (paramInt == 150)
/*  90 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/*  92 */       this.stickWidth = (1.5D * this.xScale);
/*  93 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public int getBBIdata(int paramInt)
/*     */   {
/* 100 */     if (this.ppo_parm1_parm2[paramInt] >= this.ppoEma_parm3[paramInt]) {
/* 101 */       return 1;
/*     */     }
/* 103 */     return 0;
/*     */   }
/*     */ 
/*     */   public void redrawChart(SymQuotes paramSymQuotes)
/*     */   {
/* 110 */     this.sq = paramSymQuotes;
/* 111 */     this.sym = paramSymQuotes.sym;
/*     */ 
/* 113 */     this.ma_parm1 = new float[paramSymQuotes.count];
/* 114 */     this.ma_parm2 = new float[paramSymQuotes.count];
/* 115 */     this.ppo_parm1_parm2 = new float[paramSymQuotes.count];
/* 116 */     this.ppoEma_parm3 = new float[paramSymQuotes.count];
/*     */ 
/* 118 */     if (this.noOfDays == 150)
/* 119 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else {
/* 121 */       this.stickWidth = (1.5D * this.xScale);
/*     */     }
/* 123 */     if (this.parm1 < paramSymQuotes.count) {
/* 124 */       maNdayFinder(this.parm1);
/*     */     }
/* 126 */     if (this.parm2 < paramSymQuotes.count) {
/* 127 */       maNdayFinder(this.parm2);
/* 128 */       ppo_parm1_parm2Finder();
/*     */     }
/*     */ 
/* 131 */     if (this.parm2 + this.parm3 < paramSymQuotes.count) {
/* 132 */       ppoEma_parm3Finder();
/*     */     }
/* 134 */     findMinMax();
/*     */ 
/* 136 */     if (this.ppo_parm1_parm2[(paramSymQuotes.count - 1)] >= this.ppoEma_parm3[(paramSymQuotes.count - 1)])
/* 137 */       this.trend = "Bullish";
/*     */     else {
/* 139 */       this.trend = "Bearish";
/*     */     }
/* 141 */     repaint();
/* 142 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void redrawChart()
/*     */   {
/* 149 */     if (this.parm1 < this.sq.count)
/* 150 */       maNdayFinder(this.parm1);
/*     */     else {
/* 152 */       Arrays.fill(this.ma_parm1, 0.0F);
/*     */     }
/* 154 */     if (this.parm2 < this.sq.count) {
/* 155 */       maNdayFinder(this.parm2);
/* 156 */       ppo_parm1_parm2Finder();
/*     */     } else {
/* 158 */       Arrays.fill(this.ma_parm2, 0.0F);
/* 159 */       Arrays.fill(this.ppo_parm1_parm2, 0.0F);
/*     */     }
/*     */ 
/* 162 */     if (this.parm2 + this.parm3 < this.sq.count)
/* 163 */       ppoEma_parm3Finder();
/*     */     else {
/* 165 */       Arrays.fill(this.ppoEma_parm3, 0.0F);
/*     */     }
/* 167 */     findMinMax();
/*     */ 
/* 169 */     if (this.ppo_parm1_parm2[(this.sq.count - 1)] >= this.ppoEma_parm3[(this.sq.count - 1)])
/* 170 */       this.trend = "Bullish";
/*     */     else {
/* 172 */       this.trend = "Bearish";
/*     */     }
/* 174 */     repaint();
/* 175 */     this.ep.updateValues();
/*     */   }
/*     */ 
/*     */   public void mouseMoved(MouseEvent paramMouseEvent)
/*     */   {
/* 183 */     int j = 1;
/* 184 */     if ((paramMouseEvent.getX() >= 50) && (paramMouseEvent.getX() <= 750.0F * this.xScale + 50.0F) && (paramMouseEvent.getY() >= 10) && (paramMouseEvent.getY() <= this.yScale * 100.0F + 10.0F))
/*     */     {
/* 186 */       int i = (int)((750.0F * this.xScale - (paramMouseEvent.getX() - 50) - this.stickWidth / 2.0D) / (this.stickWidth + 1.0F * this.xScale));
/*     */ 
/* 188 */       if (this.sq.count - 1 >= i)
/*     */       {
/* 190 */         j = this.sq.count - 1 - i;
/* 191 */         this.m = ("( " + (String)this.sq.date.get(j) + ", PPO[" + this.parm1 + ", " + this.parm2 + "]:" + this.df.format(this.ppo_parm1_parm2[j]) + "  PPO EMA[" + this.parm3 + "]:" + this.df.format(this.ppoEma_parm3[j]) + " )");
/*     */ 
/* 193 */         this.mX = paramMouseEvent.getX();
/* 194 */         this.mY = paramMouseEvent.getY();
/* 195 */         repaint();
/* 196 */         return;
/*     */       }
/*     */ 
/* 200 */       this.m = "";
/*     */ 
/* 202 */       repaint();
/* 203 */       return;
/*     */     }
/*     */ 
/* 207 */     this.m = "";
/* 208 */     repaint();
/*     */   }
/*     */ 
/*     */   public void mouseDragged(MouseEvent paramMouseEvent)
/*     */   {
/*     */   }
/*     */ 
/*     */   private void drawValues(Graphics2D paramGraphics2D)
/*     */   {
/* 221 */     paramGraphics2D.setPaint(Color.cyan);
/*     */ 
/* 223 */     if (this.mX + this.m.length() * 5 > 750.0F * this.xScale + 50.0F) {
/* 224 */       this.mX -= this.m.length() * 5;
/*     */     }
/* 226 */     paramGraphics2D.drawString(this.m, this.mX, this.mY);
/*     */   }
/*     */ 
/*     */   private void ppo_parm1_parm2Finder()
/*     */   {
/* 233 */     for (int i = 0; i < this.parm2; i++) {
/* 234 */       this.ppo_parm1_parm2[i] = 0.0F;
/*     */     }
/* 236 */     for (int i = this.parm2; i < this.sq.count; i++)
/*     */     {
/* 238 */       this.ppo_parm1_parm2[i] = ((this.ma_parm1[i] - this.ma_parm2[i]) / this.ma_parm1[i] * 100.0F);
/*     */     }
/*     */   }
/*     */ 
/*     */   private void ppoEma_parm3Finder()
/*     */   {
/* 247 */     for (int i = 0; i < this.parm2 + this.parm3; i++) {
/* 248 */       this.ppoEma_parm3[i] = 0.0F;
/*     */     }
/* 250 */     float f1 = 0.0F;
/* 251 */     for (int j = this.parm2 + this.parm3; j > this.parm2; j--)
/*     */     {
/* 253 */       f1 += this.ppo_parm1_parm2[j];
/*     */     }
/*     */ 
/* 257 */     this.ppoEma_parm3[(this.parm2 + this.parm3)] = (f1 / this.parm3);
/*     */ 
/* 259 */     float f2 = 2.0F / (this.parm3 + 1);
/*     */ 
/* 261 */     for (int k = this.parm2 + this.parm3 + 1; k < this.sq.count; k++)
/*     */     {
/* 263 */       this.ppoEma_parm3[k] = (this.ppo_parm1_parm2[k] * f2 + this.ppoEma_parm3[(k - 1)] * (1.0F - f2));
/*     */     }
/*     */   }
/*     */ 
/*     */   private void maNdayFinder(int paramInt)
/*     */   {
/* 273 */     for (int i = paramInt; i < this.sq.count; i++) {
/* 274 */       float f = 0.0F;
/* 275 */       for (int j = i; j > i - paramInt; j--)
/*     */       {
/* 277 */         f += ((Float)this.sq.close.get(j)).floatValue();
/*     */       }
/*     */ 
/* 281 */       if (paramInt == this.parm1)
/* 282 */         this.ma_parm1[i] = (f / paramInt);
/* 283 */       if (paramInt == this.parm2)
/* 284 */         this.ma_parm2[i] = (f / paramInt);
/*     */     }
/*     */   }
/*     */ 
/*     */   public void updateParms(int paramInt1, int paramInt2, int paramInt3)
/*     */   {
/* 293 */     this.parm1 = paramInt1;
/* 294 */     this.parm2 = paramInt2;
/* 295 */     this.parm3 = paramInt3;
/*     */ 
/* 297 */     maNdayFinder(paramInt1);
/* 298 */     maNdayFinder(paramInt2);
/* 299 */     ppo_parm1_parm2Finder();
/* 300 */     ppoEma_parm3Finder();
/*     */ 
/* 302 */     findMinMax();
/*     */   }
/*     */ 
/*     */   public Box getPPOBox(boolean paramBoolean)
/*     */   {
/* 309 */     Box localBox = Box.createHorizontalBox();
/* 310 */     TitledBorder localTitledBorder = BorderFactory.createTitledBorder("PPO");
/*     */ 
/* 312 */     this.parm1TF = new JTextField("" + this.parm1, 2);
/* 313 */     this.parm2TF = new JTextField("" + this.parm2, 2);
/* 314 */     this.parm3TF = new JTextField("" + this.parm3, 2);
/* 315 */     this.parm1TF.setFont(this.ssp10);
/* 316 */     this.parm2TF.setFont(this.ssp10);
/* 317 */     this.parm3TF.setFont(this.ssp10);
/* 318 */     this.parm1TF.setMaximumSize(new Dimension(25, 20));
/* 319 */     this.parm2TF.setMaximumSize(new Dimension(25, 20));
/* 320 */     this.parm3TF.setMaximumSize(new Dimension(25, 20));
/*     */ 
/* 322 */     JLabel localJLabel1 = new JLabel("PPO[");
/* 323 */     JLabel localJLabel2 = new JLabel(", ");
/* 324 */     JLabel localJLabel3 = new JLabel("] ,  PPO EMA[");
/* 325 */     JLabel localJLabel4 = new JLabel("]     ");
/*     */ 
/* 327 */     localJLabel1.setFont(this.ssp10);
/* 328 */     localJLabel2.setFont(this.ssp10);
/* 329 */     localJLabel3.setFont(this.ssp10);
/* 330 */     localJLabel4.setFont(this.ssp10);
/*     */ 
/* 332 */     localBox.add(localJLabel1);
/* 333 */     localBox.add(this.parm1TF);
/* 334 */     localBox.add(localJLabel2);
/* 335 */     localBox.add(this.parm2TF);
/* 336 */     localBox.add(localJLabel3);
/* 337 */     localBox.add(this.parm3TF);
/* 338 */     localBox.add(localJLabel4);
/*     */ 
/* 340 */     localBox.add(Box.createHorizontalGlue());
/*     */ 
/* 342 */     if (paramBoolean) {
/* 343 */       localBox.setBorder(localTitledBorder);
/*     */     }
/* 345 */     return localBox;
/*     */   }
/*     */ 
/*     */   public void showChgParmDialog()
/*     */   {
/* 352 */     JFrame localJFrame = new JFrame();
/* 353 */     this.chgParmDialog = new JDialog(localJFrame, "Change PPO Parameters", true);
/* 354 */     Box localBox1 = Box.createVerticalBox();
/* 355 */     Box localBox2 = Box.createHorizontalBox();
/*     */ 
/* 357 */     this.chgParmOk = new JButton("OK");
/* 358 */     this.chgParmOk.setFont(this.ssp10);
/* 359 */     this.chgParmOk.setMargin(new Insets(1, 2, 1, 2));
/* 360 */     this.chgParmOk.addActionListener(this);
/*     */ 
/* 362 */     this.chgParmCancel = new JButton("Cancel");
/* 363 */     this.chgParmCancel.setFont(this.ssp10);
/* 364 */     this.chgParmCancel.setMargin(new Insets(1, 2, 1, 2));
/* 365 */     this.chgParmCancel.addActionListener(this);
/*     */ 
/* 367 */     this.defaultParms = new JButton("Default");
/* 368 */     this.defaultParms.setFont(this.ssp10);
/* 369 */     this.defaultParms.setMargin(new Insets(1, 2, 1, 2));
/* 370 */     this.defaultParms.setToolTipText("Reset to default parameters");
/* 371 */     this.defaultParms.addActionListener(this);
/*     */ 
/* 373 */     localBox2.add(Box.createHorizontalGlue());
/* 374 */     localBox2.add(this.chgParmOk);
/* 375 */     localBox2.add(Box.createHorizontalStrut(5));
/* 376 */     localBox2.add(this.chgParmCancel);
/* 377 */     localBox2.add(Box.createHorizontalStrut(5));
/* 378 */     localBox2.add(this.defaultParms);
/* 379 */     localBox2.add(Box.createHorizontalGlue());
/*     */ 
/* 381 */     localBox1.add(getPPOBox(true));
/* 382 */     localBox1.add(localBox2);
/*     */ 
/* 384 */     this.chgParmDialog.getContentPane().add(localBox1);
/* 385 */     this.chgParmDialog.setSize(250, 100);
/* 386 */     this.chgParmDialog.setLocationRelativeTo(this.ep);
/* 387 */     this.chgParmDialog.setVisible(true);
/*     */   }
/*     */ 
/*     */   public boolean validateParm()
/*     */   {
/* 394 */     int i = this.parm1;
/* 395 */     int j = this.parm2;
/* 396 */     int k = this.parm3;
/*     */     try
/*     */     {
/* 400 */       i = Integer.parseInt(this.parm1TF.getText().trim());
/* 401 */       j = Integer.parseInt(this.parm2TF.getText().trim());
/* 402 */       k = Integer.parseInt(this.parm3TF.getText().trim());
/*     */     }
/*     */     catch (NumberFormatException localNumberFormatException)
/*     */     {
/* 408 */       JOptionPane.showMessageDialog(null, "Error in PPO parameter.Enter only numbers greater than 2.", null, 0);
/*     */ 
/* 411 */       this.parm1TF.setText("" + this.parm1);
/* 412 */       this.parm2TF.setText("" + this.parm2);
/* 413 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 415 */       return false;
/*     */     }
/*     */ 
/* 419 */     if ((i > 200) || (j > 200) || (k > 200))
/*     */     {
/* 421 */       JOptionPane.showMessageDialog(null, "Error in PPO parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 424 */       this.parm1TF.setText("" + this.parm1);
/* 425 */       this.parm2TF.setText("" + this.parm2);
/* 426 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 428 */       return false;
/*     */     }
/*     */ 
/* 432 */     if ((i < 2) || (j < 2) || (k < 2))
/*     */     {
/* 434 */       JOptionPane.showMessageDialog(null, "Error in PPO parameter.Enter values between 2 and 200.", null, 0);
/*     */ 
/* 437 */       this.parm1TF.setText("" + this.parm1);
/* 438 */       this.parm2TF.setText("" + this.parm2);
/* 439 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 441 */       return false;
/*     */     }
/*     */ 
/* 445 */     if (i >= j)
/*     */     {
/* 447 */       JOptionPane.showMessageDialog(null, "Error in PPO parameter.PPO first parameter must be less than second parameter.", null, 0);
/*     */ 
/* 450 */       this.parm1TF.setText("" + this.parm1);
/* 451 */       this.parm2TF.setText("" + this.parm2);
/* 452 */       this.parm3TF.setText("" + this.parm3);
/*     */ 
/* 454 */       return false;
/*     */     }
/*     */ 
/* 458 */     this.parm1 = i;
/* 459 */     this.parm2 = j;
/* 460 */     this.parm3 = k;
/*     */ 
/* 462 */     return true;
/*     */   }
/*     */ 
/*     */   public void actionPerformed(ActionEvent paramActionEvent)
/*     */   {
/* 469 */     if (paramActionEvent.getSource() == this.chgParmOk)
/*     */     {
/* 471 */       if (!validateParm()) {
/* 472 */         return;
/*     */       }
/* 474 */       redrawChart();
/* 475 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 479 */     if (paramActionEvent.getSource() == this.chgParmCancel)
/*     */     {
/* 481 */       this.chgParmDialog.dispose();
/*     */     }
/*     */ 
/* 485 */     if (paramActionEvent.getSource() == this.defaultParms)
/*     */     {
/* 487 */       setDefaultParms();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void setDefaultParms()
/*     */   {
/* 496 */     this.parm1TF.setText("3");
/* 497 */     this.parm2TF.setText("12");
/* 498 */     this.parm3TF.setText("6");
/*     */   }
/*     */ 
/*     */   public void vZoom(boolean paramBoolean)
/*     */   {
/* 505 */     if (paramBoolean)
/* 506 */       this.yScale += 0.2F;
/* 507 */     else if (this.yScale >= 1.2F) {
/* 508 */       this.yScale -= 0.2F;
/*     */     }
/* 510 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void hZoom(boolean paramBoolean)
/*     */   {
/* 517 */     if (paramBoolean)
/* 518 */       this.xScale += 0.2F;
/* 519 */     else if (this.xScale >= 1.2F) {
/* 520 */       this.xScale -= 0.2F;
/*     */     }
/* 522 */     if (this.noOfDays == 150)
/* 523 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 525 */       this.stickWidth = (1.5D * this.xScale);
/* 526 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   public void resetZoom()
/*     */   {
/* 533 */     this.yScale = 1.0F;
/* 534 */     this.xScale = 1.0F;
/* 535 */     if (this.noOfDays == 150)
/* 536 */       this.stickWidth = (4.0F * this.xScale);
/*     */     else
/* 538 */       this.stickWidth = (1.5D * this.xScale);
/* 539 */     setPreferredSize(new Dimension((int)(750.0F * this.xScale + 100.0F), (int)(100.0F * this.yScale + 25.0F)));
/*     */   }
/*     */ 
/*     */   protected void clear(Graphics paramGraphics)
/*     */   {
/* 546 */     super.paintComponent(paramGraphics);
/*     */   }
/*     */ 
/*     */   protected void paintComponent(Graphics paramGraphics)
/*     */   {
/* 553 */     clear(paramGraphics);
/* 554 */     Graphics2D localGraphics2D = (Graphics2D)paramGraphics;
/* 555 */     drawChart(localGraphics2D);
/* 556 */     drawValues(localGraphics2D);
/*     */   }
/*     */ 
/*     */   private void drawChart(Graphics2D paramGraphics2D)
/*     */   {
/* 587 */     this.refY = 10.0D;
/* 588 */     this.refX = 50.0D;
/* 589 */     setFont(this.ssp10);
/* 590 */     String str = "Percentage Price Oscillator";
/* 591 */     paramGraphics2D.setPaint(new Color(100, 240, 250));
/* 592 */     paramGraphics2D.drawString(str, 50, 10);
/*     */ 
/* 594 */     str = "PPO[" + this.parm1 + "," + this.parm2 + "]";
/* 595 */     paramGraphics2D.setPaint(new Color(50, 150, 255));
/* 596 */     paramGraphics2D.drawString(str, 190, 10);
/* 597 */     str = "PPO EMA[" + this.parm3 + "]";
/* 598 */     paramGraphics2D.setPaint(new Color(255, 90, 10));
/* 599 */     paramGraphics2D.drawString(str, 250, 10);
/* 600 */     str = "PPO[" + this.parm1 + "," + this.parm2 + "]-PPO EMA[" + this.parm3 + "]";
/* 601 */     paramGraphics2D.setPaint(Color.magenta);
/* 602 */     paramGraphics2D.drawString(str, 320, 10);
/*     */ 
/* 606 */     this.refL1.setLine(50.0D, 10.0D, 50.0D, this.yScale * 100.0F + 10.0F);
/* 607 */     this.refL2.setLine(750.0F * this.xScale + 50.0F, 10.0D, 750.0F * this.xScale + 50.0F, this.yScale * 100.0F + 10.0F);
/* 608 */     paramGraphics2D.setPaint(Color.white);
/* 609 */     paramGraphics2D.draw(this.refL1);
/* 610 */     paramGraphics2D.draw(this.refL2);
/*     */ 
/* 612 */     for (int i = 0; i < 14; i++)
/*     */     {
/* 614 */       this.refX += 50.0F * this.xScale;
/* 615 */       this.gridY.setLine(this.refX, 10.0D, this.refX, this.yScale * 100.0F + 10.0F);
/* 616 */       paramGraphics2D.setPaint(Color.darkGray);
/* 617 */       paramGraphics2D.draw(this.gridY);
/*     */     }
int i;
/*     */ 
/* 621 */     for (i = 0; i < 11; i++)
/*     */     {
/* 623 */       this.yrefL1.setLine(50.0D, this.refY, 40.0D, this.refY);
/* 624 */       str = this.df.format(this.maxVal - (this.maxVal - this.minVal) / 10.0F * i);
/* 625 */       paramGraphics2D.setPaint(Color.lightGray);
/* 626 */       paramGraphics2D.drawString(str, 10, (int)this.refY);
/* 627 */       this.yrefL2.setLine(750.0F * this.xScale + 50.0F, this.refY, 750.0F * this.xScale + 60.0F, this.refY);
/*     */ 
/* 629 */       paramGraphics2D.drawString(str, (int)(750.0F * this.xScale + 53.0F), (int)this.refY);
/* 630 */       this.gridX.setLine(50.0D, this.refY, 750.0F * this.xScale + 50.0F, this.refY);
/* 631 */       paramGraphics2D.setPaint(Color.white);
/* 632 */       paramGraphics2D.draw(this.yrefL1);
/* 633 */       paramGraphics2D.draw(this.yrefL2);
/* 634 */       paramGraphics2D.setPaint(Color.darkGray);
/* 635 */       paramGraphics2D.draw(this.gridX);
/* 636 */       this.refY += 10.0F * this.yScale;
/*     */     }
/*     */ 
/* 640 */     this.yfactor = (this.yScale * 100.0F / (this.maxVal - this.minVal));
/* 641 */     this.startPointX = (750.0F * this.xScale + 50.0F - (this.stickWidth + 1.0F * this.xScale));
/* 642 */     this.dateRef = (this.sq.count - 1);
/* 643 */     this.daysRef = 1;
/*     */ 
/* 645 */     this.p0Y = (this.yScale * 100.0F + 10.0F - (0.0F - this.minVal) * this.yfactor);
/* 646 */     this.l0.setLine(50.0D, this.p0Y, 750.0F * this.xScale + 50.0F, this.p0Y);
/* 647 */     paramGraphics2D.setPaint(Color.white);
/* 648 */     paramGraphics2D.draw(this.l0);
/*     */ 
/* 651 */     for (i = this.sq.count - 1; i > this.parm2; i--)
/*     */     {
/* 653 */       if (this.daysRef == this.noOfDays)
/*     */         break;
/* 655 */       paramGraphics2D.setFont(this.ssp10);
/*     */ 
/* 658 */       if (i > this.parm2 + this.parm3)
/*     */       {
/* 660 */         this.p1Y = (this.yScale * 100.0F + 10.0F - (this.ppoEma_parm3[i] - this.minVal) * this.yfactor);
/* 661 */         this.p2Y = (this.yScale * 100.0F + 10.0F - (this.ppoEma_parm3[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 663 */         this.l1.setLine(this.startPointX, this.p1Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p2Y);
/* 664 */         paramGraphics2D.setPaint(new Color(255, 90, 10));
/* 665 */         paramGraphics2D.draw(this.l1);
/*     */ 
/* 667 */         this.hY = (this.yScale * 100.0F + 10.0F - (this.ppo_parm1_parm2[i] - this.ppoEma_parm3[i] - this.minVal) * this.yfactor);
/* 668 */         this.hL.setLine(this.startPointX, this.p0Y, this.startPointX, this.hY);
/* 669 */         paramGraphics2D.setPaint(Color.magenta);
/* 670 */         paramGraphics2D.draw(this.hL);
/*     */       }
/*     */ 
/* 674 */       if (i > this.parm2)
/*     */       {
/* 676 */         this.p11Y = (this.yScale * 100.0F + 10.0F - (this.ppo_parm1_parm2[i] - this.minVal) * this.yfactor);
/* 677 */         this.p22Y = (this.yScale * 100.0F + 10.0F - (this.ppo_parm1_parm2[(i - 1)] - this.minVal) * this.yfactor);
/*     */ 
/* 679 */         this.l2.setLine(this.startPointX, this.p11Y, this.startPointX - this.stickWidth - 1.0F * this.xScale, this.p22Y);
/* 680 */         paramGraphics2D.setPaint(new Color(50, 150, 255));
/* 681 */         paramGraphics2D.draw(this.l2);
/*     */       }
/*     */ 
/* 685 */       if ((i > this.parm2 + this.parm3) && (this.ppo_parm1_parm2[i] - this.ppoEma_parm3[i] >= 0.0F) && (this.ppo_parm1_parm2[(i - 1)] - this.ppoEma_parm3[(i - 1)] < 0.0F))
/*     */       {
/* 687 */         this.x1 = this.startPointX;
/* 688 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 689 */         this.y1 = this.p1Y;
/* 690 */         this.y2 = this.p2Y;
/* 691 */         this.u1 = this.x1;
/* 692 */         this.u2 = this.x2;
/* 693 */         this.v1 = this.p11Y;
/* 694 */         this.v2 = this.p22Y;
/*     */ 
/* 696 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 697 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 699 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 700 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 702 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 703 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 705 */         paramGraphics2D.setPaint(Color.green);
/* 706 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 707 */         this.lA.setLine(this.xi, this.yi - 5.0D, this.xi - 3.0D, this.yi);
/* 708 */         this.hA.setLine(this.xi, this.yi - 5.0D, this.xi + 3.0D, this.yi);
/* 709 */         paramGraphics2D.draw(this.uA);
/* 710 */         paramGraphics2D.draw(this.lA);
/* 711 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 715 */       if ((i > this.parm2 + this.parm3) && (this.ppo_parm1_parm2[i] - this.ppoEma_parm3[i] < 0.0F) && (this.ppo_parm1_parm2[(i - 1)] - this.ppoEma_parm3[(i - 1)] > 0.0F))
/*     */       {
/* 717 */         this.x1 = this.startPointX;
/* 718 */         this.x2 = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 719 */         this.y1 = this.p1Y;
/* 720 */         this.y2 = this.p2Y;
/* 721 */         this.u1 = this.x1;
/* 722 */         this.u2 = this.x2;
/* 723 */         this.v1 = this.p11Y;
/* 724 */         this.v2 = this.p22Y;
/*     */ 
/* 726 */         this.b1 = ((this.y1 - this.y2) / (this.x1 - this.x2));
/* 727 */         this.a1 = (this.y1 - this.b1 * this.x1);
/*     */ 
/* 729 */         this.b2 = ((this.v1 - this.v2) / (this.u1 - this.u2));
/* 730 */         this.a2 = (this.v1 - this.b2 * this.u1);
/*     */ 
/* 732 */         this.xi = (-1.0D * (this.a1 - this.a2) / (this.b1 - this.b2));
/* 733 */         this.yi = (this.a1 + this.b1 * this.xi);
/*     */ 
/* 735 */         paramGraphics2D.setPaint(Color.red);
/* 736 */         this.uA.setLine(this.xi, this.yi - 5.0D, this.xi, this.yi + 5.0D);
/* 737 */         this.lA.setLine(this.xi, this.yi + 5.0D, this.xi - 3.0D, this.yi);
/* 738 */         this.hA.setLine(this.xi, this.yi + 5.0D, this.xi + 3.0D, this.yi);
/* 739 */         paramGraphics2D.draw(this.uA);
/* 740 */         paramGraphics2D.draw(this.lA);
/* 741 */         paramGraphics2D.draw(this.hA);
/*     */       }
/*     */ 
/* 745 */       if (this.dateRef == i)
/*     */       {
/* 747 */         paramGraphics2D.setFont(this.ssp9);
/* 748 */         str = ((String)this.sq.date.get(i)).substring(0, 6);
/* 749 */         if (this.ppo_parm1_parm2[i] >= this.ppoEma_parm3[i])
/* 750 */           paramGraphics2D.setPaint(Color.green);
/*     */         else {
/* 752 */           paramGraphics2D.setPaint(Color.red);
/*     */         }
/* 754 */         paramGraphics2D.drawString(str, (int)this.startPointX, (int)(this.yScale * 100.0F + 20.0F));
/* 755 */         if (this.noOfDays == 150)
/* 756 */           this.dateRef -= 10;
/*     */         else
/* 758 */           this.dateRef -= 20;
/* 759 */         paramGraphics2D.setFont(this.ssp10);
/*     */       }
/*     */ 
/* 763 */       this.startPointX = (this.startPointX - this.stickWidth - 1.0F * this.xScale);
/* 764 */       this.daysRef += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   private void findMinMax()
/*     */   {
/* 773 */     int i = 1;
/* 774 */     this.minVal = this.ppo_parm1_parm2[(this.sq.count - 1)];
/* 775 */     this.maxVal = this.ppo_parm1_parm2[(this.sq.count - 1)];
/*     */ 
/* 777 */     for (int j = this.sq.count - 1; j >= this.parm2; j--)
/*     */     {
/* 779 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 782 */       if (this.minVal > this.ppo_parm1_parm2[j]) {
/* 783 */         this.minVal = this.ppo_parm1_parm2[j];
/*     */       }
/* 785 */       if (this.maxVal < this.ppo_parm1_parm2[j]) {
/* 786 */         this.maxVal = this.ppo_parm1_parm2[j];
/*     */       }
/* 788 */       i += 1;
/*     */     }
/*     */ 
/* 792 */     i = 1;
/* 793 */     for (int j = this.sq.count - 1; j >= this.parm2 + this.parm3; j--)
/*     */     {
/* 795 */       if (i > this.noOfDays) {
/*     */         break;
/*     */       }
/* 798 */       if (this.minVal > this.ppoEma_parm3[j])
/* 799 */         this.minVal = this.ppoEma_parm3[j];
/* 800 */       if (this.minVal > this.ppo_parm1_parm2[j] - this.ppoEma_parm3[j]) {
/* 801 */         this.minVal = (this.ppo_parm1_parm2[j] - this.ppoEma_parm3[j]);
/*     */       }
/* 803 */       if (this.maxVal < this.ppoEma_parm3[j])
/* 804 */         this.maxVal = this.ppoEma_parm3[j];
/* 805 */       if (this.maxVal < this.ppo_parm1_parm2[j] - this.ppoEma_parm3[j]) {
/* 806 */         this.maxVal = (this.ppo_parm1_parm2[j] - this.ppoEma_parm3[j]);
/*     */       }
/* 808 */       i += 1;
/*     */     }
/*     */   }
/*     */ 
/*     */   public static void main(String[] paramArrayOfString)
/*     */   {
/* 873 */     FileDownloader localFileDownloader = new FileDownloader();
/* 874 */     localFileDownloader.downloadFiles();
/* 875 */     SymQuotes localSymQuotes = new SymQuotes("WIPRO", localFileDownloader.datesToRead, 1, 1, "ns");
/*     */ 
/* 877 */     PPOChart localPPOChart = new PPOChart(localSymQuotes, 3, 12, 6);
/*     */ 
/* 879 */     JFrame localJFrame = new JFrame("Test");
/* 880 */     localJFrame.setDefaultCloseOperation(3);
/* 881 */     localJFrame.getContentPane().add(localPPOChart);
/* 882 */     localJFrame.pack();
/* 883 */     localJFrame.setSize(850, 175);
/* 884 */     localJFrame.setVisible(true);
/*     */   }
/*     */ 
/*     */   public class EastPanel extends JPanel
/*     */   {
/*     */     private JLabel title;
/*     */     private JLabel ppoL;
/*     */     private JLabel ppoEmaL;
/*     */     private JLabel trendL;
/*     */     private ChartHelpButton chb;
/* 821 */     private Font valuesF = new Font("Sanserif", 0, 11);
/* 822 */     public Box buttonsPanel = Box.createHorizontalBox();
/*     */ 
/*     */     public EastPanel()
/*     */     {
/* 826 */       this.title = new JLabel("PPO");
/* 827 */       this.ppoL = new JLabel("PPO[" + PPOChart.this.parm1 + ", " + PPOChart.this.parm2 + "]: " + PPOChart.this.df.format(PPOChart.this.ppo_parm1_parm2[(PPOChart.this.sq.count - 1)]));
/* 828 */       this.ppoEmaL = new JLabel("PPO EMA[" + PPOChart.this.parm3 + "]: " + PPOChart.this.df.format(PPOChart.this.ppoEma_parm3[(PPOChart.this.sq.count - 1)]));
/*     */ 
/* 830 */       this.trendL = new JLabel("Trend: " + PPOChart.this.trend);
/* 831 */       this.chb = new ChartHelpButton("http://www.profitindicators.com/home/indicators/ppo.htm", "Help on PPO");
/*     */ 
/* 833 */       this.chb.setFont(this.valuesF);
/*     */ 
/* 835 */       this.ppoL.setFont(this.valuesF);
/* 836 */       this.ppoEmaL.setFont(this.valuesF);
/* 837 */       this.trendL.setFont(this.valuesF);
/*     */ 
/* 839 */       this.buttonsPanel.add(this.chb);
/* 840 */       this.buttonsPanel.add(Box.createHorizontalStrut(2));
/* 841 */       this.buttonsPanel.setAlignmentX(0.0F);
/*     */ 
/* 843 */       setLayout(new BoxLayout(this, 3));
/*     */ 
/* 845 */       add(this.title);
/* 846 */       add(this.ppoL);
/* 847 */       add(this.ppoEmaL);
/* 848 */       add(new JLabel(" "));
/* 849 */       add(this.trendL);
/* 850 */       add(this.buttonsPanel);
/* 851 */       add(Box.createVerticalGlue());
/*     */ 
/* 853 */       setBackground(new Color(243, 245, 252));
/*     */     }
/*     */ 
/*     */     public void updateValues()
/*     */     {
/* 860 */       this.ppoL.setText("PPO[" + PPOChart.this.parm1 + ", " + PPOChart.this.parm2 + "]: " + PPOChart.this.df.format(PPOChart.this.ppo_parm1_parm2[(PPOChart.this.sq.count - 1)]));
/* 861 */       this.ppoEmaL.setText("PPO EMA[" + PPOChart.this.parm3 + "]: " + PPOChart.this.df.format(PPOChart.this.ppoEma_parm3[(PPOChart.this.sq.count - 1)]));
/* 862 */       this.trendL.setText("Trend: " + PPOChart.this.trend);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Deebak\Downloads\profitindicatorsv2-05.jar
 * Qualified Name:     PPOChart
 * JD-Core Version:    0.6.0
 */